﻿using DI;
using Core.Context;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using StructureMap.Pipeline;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Library.Logging;
using Core.Domain;
using Core.IRepository.Admin;
using Core.Factories;
using Core.IServices;
using Repositories.Admin;
using CMS.Repositories;

namespace Tests.Assembler
{
    [TestClass]
    public class BootstrapperTest
    {
        [TestInitialize()]
        public void Initialize()
        {
            Bootstrapper.Init(new SingletonLifecycle());
        }

        [TestCleanup()]
        public void Cleanup()
        {

        }

        [TestMethod]
        public void Bootstrapper_IAppSetting_Can_Load()
        {
            //Act
            var settings = Bootstrapper.Resolve<IAppSettings>();

            //Assert
            Assert.IsNotNull(settings);
            Assert.IsTrue(settings.List_PageSize > 0);
        }

        [TestMethod]
        public void Bootstrapper_ILogger_Can_Load()
        {
            //Act
            var obj = Bootstrapper.Resolve<ILogger>();

            //Assert
            Assert.IsNotNull(obj);
        }

        [TestMethod]
        public void Bootstrapper_IAdminRepository_Can_Load()
        {
            //Act
            var obj = Bootstrapper.Resolve<IAdminRepository<byte, Culture>>();
            var list = obj.FindAll();

            //Assert
            Assert.IsNotNull(obj);
            Assert.IsNotNull(list);
        }

        [TestMethod]
        public void Bootstrapper_ISettingsFactory_Can_Load()
        {
            //Act
            var obj = Bootstrapper.Resolve<ISettingsFactory>();

            //Assert
            Assert.IsNotNull(obj);
        }

        [TestMethod]
        public void Bootstrapper_IReadSettingService_Can_Load()
        {
            //Act
            var obj = Bootstrapper.Resolve<IReadSettingService>();
            var list = obj.GetAll();

            //Assert
            Assert.IsNotNull(obj);
            Assert.IsNotNull(list);
        }

        [TestMethod]
        public void Bootstrapper_IReadCultureService_Can_Load()
        {
            //Act
            var obj = Bootstrapper.Resolve<IReadCultureService>();
            var list = obj.GetAll();

            //Assert
            Assert.IsNotNull(obj);
            Assert.IsNotNull(list);
        }

        [TestMethod]
        public void Bootstrapper_AdminDbContext_Can_Load()
        {
            //Act
            var obj = Bootstrapper.Resolve<AdminDbContext>();
            var list = obj.Cultures.ToList();

            //Assert
            Assert.IsNotNull(obj);
            Assert.IsNotNull(list);
        }
    }
}
